package com.mf.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mf.common.service.impl.BaseServiceImpl;
import com.mf.dao.EslesmeDAO;
import com.mf.dao.KullaniciDAO;
import com.mf.model.Eslesme;
import com.mf.model.Kullanici;
import com.mf.service.EslesmeService;

@Service
public class EslesmeServiceImpl extends BaseServiceImpl implements EslesmeService {
	@Autowired
	private EslesmeDAO eslesmeDAO;
	@Autowired
	private KullaniciDAO kullaniciDAO;

	@Transactional
	public List<Eslesme> getEslesmeList(int id) {

		Kullanici kullanici = (Kullanici) kullaniciDAO.findById(Kullanici.class, id);
		List<Eslesme> fromEeslesmeList = (List<Eslesme>) eslesmeDAO.findByProperty(Eslesme.class, "from", kullanici);
		List<Eslesme> toEslesmeList = (List<Eslesme>) eslesmeDAO.findByProperty(Eslesme.class, "to", kullanici);

		List<Eslesme> allList = fromEeslesmeList;
		allList.addAll(toEslesmeList);
		return allList;
	}
}